package com.shxc.smarttrade.old.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.shxc.smarttrade.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by jcdev1 on 2017/6/17.
 */

public class ChangeNameActivity extends BaseActivity {


    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.tv_center)
    TextView tvCenter;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.iv_delete)
    ImageView ivDelete;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_name);
        ButterKnife.bind(this);
        initView();
    }

    /**
     * 初始化View
     */
    private void initView() {
        tvLeft.setText("取消");
        tvCenter.setText("昵称");
        tvRight.setText("保存");

    }

    @OnClick({R.id.tv_left, R.id.tv_right, R.id.iv_delete})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_left:
                finish();
                break;
            case R.id.tv_right:
                //保存
                String name = etName.getText().toString().trim();
                if (!TextUtils.isEmpty(name)) {
                    Intent intent = new Intent();
                    intent.putExtra("name", name);
                    setResult(520, intent);
                    finish();
                } else {
                    showToast("无效的昵称");
                }
                break;
            case R.id.iv_delete:
                etName.setText("");
                break;
        }
    }
}
